<template>
	<view class="work-container">
		<!-- <z-paging ref="paging" v-model="dataList" @query="queryList"> -->
		<scroll-view class="scroll-view_H" scroll-y="true" @scroll="scroll">
			<view class="item flex align-center p-t-5 p-b-5" v-for="(item,index) in dataList" :key="index"
				@click="toDeptDetail(item)">
				<u--image width="70" height="70"
					:src="item.deptImg?item.deptImg:require('@/static/images/homeIndex/dept-ico.png')"
					shape="circle"></u--image>
				<view style="flex: 1;" class="flex flex-column justify-around p-l-16 p-t-10 p-b-10">
					<view class="flex align-center justify-between m-b-10">
						<view class="flex align-center">
							<text style="font-size: 32rpx;color: #323232;" class="m-r-20">{{item.deptName}}</text>
							<text style="font-size: 26rpx;color: #323232;">{{deptTrans[item.deptType]}}</text>
						</view>
						<img style="width: 40rpx;" src="@/static/images/arrow-right.svg" alt="">
					</view>
					<text class="overEllips" style="font-size: 26rpx;color: #999999;">{{item.articleTitle}}</text>

				</view>
			</view>
		</scroll-view>
		<!-- </z-paging> -->
	</view>
</template>

<script>
	import {
		getDeptList
	} from "@/api/home/home.js";
	import {
		getDictType
	} from "@/api/system/public.js";
	export default {
		data() {
			return {
				dataList: [],
				hospitalCode: '',
				deptTrans: {}
			}
		},
		onLoad: function() {
			let hosCode = uni.getStorageSync('hospital') || ''
			this.hospitalCode = JSON.parse(hosCode).hospitalCode
			this.getData()
			this.getDict()
			
		},
		onPullDownRefresh() {
			this.getData()
		},
		methods: {
			toDeptDetail(res) {
				uni.navigateTo({
					url: '/pages/home/deptDetail?id=' + res.id + '&deptName=' + res.deptName  + '&deptCode=' + res.deptCode
				})
			},
			getData() {
				getDeptList({
					hospitalCode: this.hospitalCode,
					isShow: '1'
				}).then(res => {
					console.log(res)
					// 将请求结果通过complete传给z-paging处理，同时也代表请求结束，这一行必须调用
					// this.$refs.paging.complete(res.rows);
					this.dataList = res.rows
					//数据请求完成之后停止下拉刷新
					uni.stopPullDownRefresh();
				});
			},
			// @query所绑定的方法不要自己调用！！需要刷新列表数据时，只需要调用this.$refs.paging.reload()即可
			// queryList(pageNum, pageSize) {
			// 	// 此处请求仅为演示，请替换为自己项目中的请求
			// 	getDeptList({
			// 		hospitalCode: this.hospitalCode,
			// 		pageNum: pageNum,
			// 		pageSize: pageSize
			// 	}).then(res => {
			// 		console.log(res)
			// 		// 将请求结果通过complete传给z-paging处理，同时也代表请求结束，这一行必须调用
			// 		this.$refs.paging.complete(res.rows);
			// 	});
			// },
			/* 字典 */
			getDict() {
				getDictType({
					dictType: 'department_type'
				}).then(res => {
					res.rows.forEach(item => {
						this.deptTrans[item.dictValue] = item.dictLabel
					})
				});
			},
		}
	}
</script>

<style scoped lang="scss">
	page {
		height: 100%;

		.scroll-view_H {
			width: 100%;
			height: calc(100vh - 40rpx);
			background-color: #F6F7F9;
		}

		.work-container {
			width: 100%;
			height: 100%;
			background-color: #F6F7F9;

			.item {
				width: 94%;
				margin-left: 3%;
				height: 160rpx;
				padding: 30rpx 20rpx;
				margin-top: 20rpx;
				border-radius: 12rpx;
				background-color: #fff;

				.overEllips {
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
				}

				.avatar {
					width: 120rpx;
					height: 120rpx;
				}
			}

		}

	}
</style>